package com.jeeplus.modules.flowable.listener;

import com.jeeplus.modules.flowable.CheckCycle.Service.BasicdataCheckStandardMainCycleService;
import com.jeeplus.modules.flowable.CheckCycle.entity.BasicdataCheckStandardMainCycle;
import com.jeeplus.modules.flowable.myListenerService.service.MyJianLongListenterService;
import com.jeeplus.modules.flowable.service.FlowTaskService;
import com.jeeplus.modules.flowable.web.FlowableTaskController;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.task.api.Task;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component("myExecutionListener")
public class MyExecutionListener implements ExecutionListener {

    private static MyExecutionListener myExecutionListener;

    @Autowired
    BasicdataCheckStandardMainCycleService basicdataCheckStandardMainCycleService;

    @Autowired
    FlowTaskService flowTaskService;

    @Autowired
    TaskService taskService;

    @PostConstruct
    public void init(){
        myExecutionListener = this;
        myExecutionListener.basicdataCheckStandardMainCycleService = this.basicdataCheckStandardMainCycleService;
        myExecutionListener.taskService = this.taskService;
        myExecutionListener.flowTaskService = this.flowTaskService;
    }

    @SneakyThrows
    @Override
    public void notify(DelegateExecution delegateExecution) {

        String eventName = delegateExecution.getEventName();
        if ("start".equals(eventName)) {
            System.out.println("start=========");
        }else if ("end".equals(eventName)) {
            System.out.println("end=========");
        } else if ("take".equals(eventName)) {//连线监听
            System.out.println("take=========");
        }
    }
}
